<!-- BEGIN .main-navigation -->
<section class="main-navigation clearfix">
    <nav>
        <?php $this->widget('BreadcrumbsWidget',array('data' => $this->breadcrumbs))?>
        <div class="title">
		<?php echo $category->name?>
        </div>
    </nav>
    <!-- END .main-navigation -->
</section>
<section class="main-content-wrapper clearfix">
    <section class="catalog">

        <div class="sorting clearfix">
            <form action="<?php echo Yii::app()->request->requestUri?>" method="post">
                <label>Xếp theo:</label>
                <select name="sort" id="sort">
                    <?php foreach(getSort() as $key => $value):?>
                        <option value="<?php echo $key?>" <?php echo $key == $sort?"selected='selected'":""?>><?php echo $value?></option>
                    <?php endforeach;?>
                </select>
            </form>
        </div>

        <div class="items clearfix">
            <?php foreach($products as $product):?>
            <div class="item-block-1">
                <?php if($product->getSale() !== false):?>
                    <span class="tag-sale">
                        <div>-<?php echo $product->getSale()?>%</div>
                    </span>
                <?php endif;?>
                <div class="image-wrapper">
                    <div class="image">
                        <a href="<?php echo $product->getUrl()?>">
                            <img src="<?php echo urlImageFolder('product').$product->getImage()?>" style="margin: -32.5px 0 0 0;" alt="" />
                        </a>
                    </div>
                </div>
                <h2>
                    <a href="<?php echo $product->getUrl()?>"><?php echo $product->name;?></a>
                </h2>
                <p class="price"><?php echo number_format($product->getPrice(),0,0,'.') ?> VND
                    <?php if($product->getOldPrice() != 0):?>
                        <s><?php echo number_format($product->getOldPrice(),0,0,'.') ?> VND</s>
                    <?php endif;?>
                </p>
            </div>
            <?php endforeach;?>
            <div class="clearBoth" id="bottom_list"></div>
        </div>
        <div class="clearBoth"></div>
        <div id="view_more" style="text-align: center;padding:10px 0px;margin-top: 20px;color: #fff;background: #EB6998;font-size: 20px;cursor: pointer;border-radius: 4px;">
            <img src="<?php echo UrlImage()?>ajax-loader.gif" style="margin-bottom: -7px;margin-right: 7px;display: none"/>Xem Thêm
        </div>
        <!-- END .catalog -->
    </section>
</section>
<script>
    $(document).ready(function(){
        
        $('#view_more').live('click',function(){
            $(this).find('img').show();
            $.ajax({
                url: '<?php echo Yii::app()->createUrl('category/more',array('id' => $category->id))?>',
                type: 'GET',
                dataType: 'html',
                data:{'sort':$('#sort').val(),'offset':$('.items .item-block-1').size()},
                success: function(data){
                    if(data.length > 0){
                        $('#bottom_list').before(data);
                    }else{
                        $('#view_more').hide();
                    }
                }
            }).done(function(){
                $('#view_more img').hide();
            });
        });
    });
</script>